package com.ruoyi.industry.controller.pc;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.industry.domain.SpaceCollect;
import com.ruoyi.industry.domain.SpaceIndustry;
import com.ruoyi.industry.service.ISpaceCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 空间收藏Controller
 *
 * @author MagicCube
 * @date 2023-05-23
 */
@RestController
@RequestMapping("/frontend/collect")
public class SpaceCollectController extends BaseController
{
    @Autowired
    private ISpaceCollectService spaceCollectService;

    /**
     * 查询空间收藏列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SpaceCollect spaceCollect)
    {
        startPage();
        List<SpaceIndustry> list = spaceCollectService.selectSpaceCollectList(spaceCollect);
        return getDataTable(list);
    }

    /**
     * 新增空间收藏
     */
    @Log(title = "空间收藏", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SpaceCollect spaceCollect)
    {
        return toAjax(spaceCollectService.insertSpaceCollect(spaceCollect));
    }

    /**
     * 删除空间收藏
     */
    @Log(title = "空间收藏", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable String id)
    {
        return toAjax(spaceCollectService.deleteSpaceCollectById(id));
    }
}
